<cfparam default="none" name="url.SCFStep1" />
<cfparam default="none" name="url.SCFStep2" />
<cfparam default="none" name="url.SCFStep3" />
<cfparam default="none" name="url.SCFStep4" />
<cfparam default="none" name="url.SCFStep5" />
<cfparam default="none" name="url.SCFStep6" />

<!---NonSCF--->
<cfparam default="none" name="url.NonSCFStep1" />
<cfparam default="none" name="url.NonSCFStep3" />
<cfparam default="none" name="url.NonSCFStep4" />
<cfparam default="none" name="url.NonSCFStep6" />


<!--- SCFStep1 --->
<cfif url.SCFStep1 eq "add">
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST">
            <cfscript>
                import models.*;                
                employee = EntityNew("Employee");
                employee.setFirstName( FORM.FirstName );
                employee.setLastName( FORM.LastName );
                employee.setMiddleName( FORM.MiddleName );
                employee.setPreferredName( FORM.PreferredName );
                ( FORM.HomePhone NEQ "" ? employee.setHomePhone( Replace( FORM.HomePhone, "-", "", "All") ) : 'NULL' );
                ( FORM.WorkPhone NEQ "" ? employee.setWorkPhone( Replace( FORM.WorkPhone, "-", "", "All") ) : 'NULL' );
                ( FORM.CellPhone NEQ "" ? employee.setCellPhone( Replace( FORM.CellPhone, "-", "", "All") ) : 'NULL' );
                employee.setWorkPhoneExtention( FORM.WorkPhoneExtention );
                employee.setPhonePrimaryID( FORM.PhonePrimaryID );
                employee.setEmail( FORM.Email );
                employee.setAddress1( FORM.Address1 );
                ( FORM.Address2 NEQ "" ? employee.setAddress2( FORM.Address2 ) : 'NULL' );
                employee.setCity( FORM.City );
                employee.setState( FORM.State );
                employee.setZip( FORM.Zip );
                employee.setPostingID( FORM.PostingID );
                employee.setSupervisorID( Session.EmpInfo.MasterID );
                employee.setDepartmentID( FORM.DepartmentID );
                employee.setMirrorAccountID( 0 );
                employee.setDeskPhone( FORM.DeskPhone );
                employee.setBadgeAccessLevelID( FORM.BadgeAccessLevelID );
                employee.setTimeCardApprs( FORM.TimeCardAppr );
                employee.setContainerID( FORM.ContainerID );
                employee.setCostCode( FORM.CostCode ); 
                employee.setLunchID( FORM.LunchID );
                ( isDefined("FORM.Benefits") ? employee.setBenefits( 1 ) : employee.setBenefits( 0 ) );
                ( isDefined("FORM.Leave") ? employee.setLeave( 1 ) : employee.setLeave( 0 ) );
                EntitySave(employee, true);
                                               
                stepAction = EntityNew("StepActions");
                stepAction.setEmployeeID(employee.getEmployeeID());
                stepAction.setStepsID(1);
                stepAction.setActionByID(Session.UserRosettaID);
                stepAction.setCreationTimeStamp(now());
                stepAction.setNotes(replace(trim(FORM.Comments),"'","''","all"));
                EntitySave(stepAction, true);
                stepAction = EntityNew("StepActions");
                stepAction.setEmployeeID(employee.getEmployeeID());
                stepAction.setStepsID(2);
                stepAction.setNotes(replace(trim(FORM.Comments),"'","''","all"));
                stepAction.setCreationTimeStamp(now());
                EntitySave(stepAction, true);
                                             
                Session.StepConfirmation = '<h1 class="title">Step 1: Confirmation</h1>';
                Session.StepConfirmation &= "The process to hire " & FORM.FirstName & " " & ( FORM.PreferredName NEQ "" ? "(" & FORM.PreferredName & ")" : "") & " " & ( FORM.MiddleName NEQ "" ? FORM.MiddleName : "" ) & " " & FORM.LastName;
                Session.StepConfirmation &= " has been successfully submitted to HR.  Please wait for confirmation of offer acceptance and estimated start date.  Thank you for using E-PAR. <p>Hire another employee? Click <a href='../SCF/Step1-Hire.cfm'>Here</a>";
                location("confirmation.cfm");
            </cfscript>
        </cfcase>
    </cfswitch>
</cfif>
<!--- SCFStep1 --->


<!--- SCFStep2 --->
<cfif url.SCFStep2 eq "update">
    <cfparam default="0" name="url.Decline" />
    <cfswitch expression="#CGI.REQUEST_METHOD#">        
        <cfcase value="POST">

            <cfscript>
                import models.*;                
                StepAction = EntityLoad ("StepActions", FORM.StepID);
                employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                employee = employee[1];
                StepAction = stepAction[1];
                employee.setFirstName(FORM.FirstName);
                employee.setLastName(FORM.LastName);
                employee.setMiddleName(FORM.MiddleName);
                employee.setPreferredName(FORM.PreferredName);
                employee.setCostCode(FORM.CostCode);
                ( isDefined("FORM.Benefits") ? employee.setBenefits( 1 ) : employee.setBenefits( 0 ) );
                ( isDefined("FORM.Leave") ? employee.setLeave( 1 ) : employee.setLeave( 0 ) );
                ( FORM.HomePhone NEQ "" ? employee.setHomePhone( Replace( FORM.HomePhone, "-", "", "All") ) : 'NULL' );
                ( FORM.WorkPhone NEQ "" ? employee.setWorkPhone( Replace( FORM.WorkPhone, "-", "", "All") ) : 'NULL' );
                ( FORM.CellPhone NEQ "" ? employee.setCellPhone( Replace( FORM.CellPhone, "-", "", "All") ) : 'NULL' );
                employee.setWorkPhoneExtention( FORM.WorkPhoneExtention );
                employee.setEmail( FORM.Email );
                employee.setPositionID( FORM.PositionID );
                employee.setDepartmentID( FORM.DepartmentID );
                employee.setSupervisorID( FORM.SupervisorID );
                employee.setEmployeeCodeID( FORM.EmployeeCodeID );
                employee.setEstStartDate( FORM.EstStartDate );                
                employee.setSalaryHourlyID( FORM.SalaryHourlyID );
                employee.setShiftID( FORM.ShiftID );
                employee.setHoursPerWeek( FORM.HoursPerWeek );
                ( isDefined("FORM.Primary") ? employee.setPrimary( 1 ) : employee.setPrimary( 0 ) );
                ( isDefined("FORM.Exempt") ? employee.setExempt( 1 ) : employee.setExempt( 0 ) );
                ( isDefined("FORM.FullTime") ? employee.setFullTime( 1 ) : employee.setFullTime( 0 ) );
                ( isDefined("FORM.Seasonal") ? employee.setSeasonal( 1 ) : employee.setSeasonal( 0 ) );
                employee.setDaily( FORM.Daily );
                employee.setWorkersCompID( FORM.WorkersCompID );
                employee.setCompTypeID( FORM.CompTypeID );
                employee.setFrequencyID( listToArray(FORM.FrequencyID, ':')[1] );
                employee.setPayRate( FORM.PayRate );
                employee.setDaily( FORM.Daily );
                ( URL.Decline == 0 ? employee.setOfferAccepted( 1 ) : employee.setOfferAccepted( 0 ) );
                
                EntitySave(employee);
                
                StepAction.setActionByID( Session.UserRosettaID );
                StepAction.setNotes( FORM.Notes );
                StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                
                EntitySave(StepAction);
                
                if( URL.Decline == 0 ){
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID(employee.getEmployeeID());
                    InsertAction.setStepsID(3);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                }else{
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Delcined - #FORM.Notes#' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                }
                
                KronosQueries = CreateObject("component", session.RootDir & ".DatabaseQueries.Kronos");
                GetFrequency = KronosQueries.funcGetFrequency( listToArray(FORM.FrequencyID, ':')[1] );
                GetPositionInfo = KronosQueries.funcGetPositionCodes( FORM.PositionID );
                GetDepts = KronosQueries.funcGetDepts( FORM.DepartmentID );
                GetSalaryHourly = KronosQueries.funcGetSalaryHourly( FORM.SalaryHourlyID );
                if( !IsDefined("SCF_Employee_GetEmployeeInfo_Basic") ){
                    include "/code_lib/SCF_Employee.cfm";        
                }
                Supervisor = SCF_Employee_GetEmployeeInfo_Basic( FORM.SupervisorID );
                yes = 'yes';
                no = 'no';                
                Session.StepConfirmation = '<h1 class="title">Step 2: Confirmation</h1>';
                Session.StepConfirmation &= '<div class="entry">';
                Display = ( URL.Decline == 0 ? "The individual chose to <strong>accept</strong> the offer and their record has been updated with the following information:" :  "The individual chose to <strong>reject</strong> the offer.  The offer, as presented, appears below. ");
                Subject = ( URL.Decline == 0 ? "Employee Update: Hired" : "Employee Update: Offer Not Accepted");
                Session.StepConfirmation &= '<p>#Display#</p>';
                Session.StepConfirmation &= '
                    <table>
                        <tr>
                            <td width=25>&nbsp;</td>
                            <td>
                                <p>                                    
                                    Employee to Hire: #FORM.FirstName# #FORM.LastName#<br>
                                    Est Start Date: #DateFormat(FORM.EstStartDate, "mm/dd/yyyy")# <br>
                                    Exempt: ' & ( isDefined("FORM.Exempt") ? yes : no ) & '<br>
                                    Full Time: ' & ( isDefined("FORM.FullTime") ? yes : no ) & '<br>
                                    Seasonal: ' & ( isDefined("FORM.Seasonal") ? yes : no ) & '<br>
                                    Primary Position: ' & ( isDefined("FORM.Primary") ? yes : no ) & '<br>
                                    Position Code: #GetPositionInfo.PositionCode#<br>
                                    Position Title: #GetPositionInfo.PositionCodeDescription#  <br>
                                    Department: #GetDepts.Org#<br>
                                    Supervisor: #Supervisor.FirstName# #Supervisor.LastName# <br><br>
                                    Cost Code: #FORM.CostCode#   <br>
                                    Leave Eligible: ' & ( isDefined("FORM.Leave") ? yes : no ) & '<br>
                                    Benefits Eligible: ' & ( isDefined("FORM.Benefits") ? yes : no ) & '<br>
                                    Salary/Hourly: #GetSalaryHourly.PersonCode#<br>
                                    Hours Per Week: #FORM.HoursPerWeek#<br>
                                    Pay Rate: $#FORM.PayRate#<br>
                                    Frequency: #GetFrequency.PayRateFrequencyCode# <br>
                                    Annual Rate: $#(FORM.PayRate * GetFrequency.AnnualizingFactor)#<br/>
                                    Comments: #FORM.Notes#
                                </p>
                            </td>
                        </tr>
                    </table>                     
                    <p>Thank you for using E-PAR. A status update has been sent via email to the supervisor.</p>                    
                    <p>Enter "Pre-Orientation" data for another user?  Click <a href="Step2-PreOrientation.cfm">Here</a></p>';                
                Session.StepConfirmation &= '</div>';                
            </cfscript>
            <cfoutput>
            <cfmail from="HR Dept - EPAR System <noreply@scf.cc>" to="#Supervisor.Email#" type="html" subject="#Subject#">
            <p>#Display# Please contact HR with any questions you may have.</p>
            <table>
                <tr>
                    <td width=25>&nbsp;</td>
                    <td>
                        <p> 
                            Employee to Hire: #FORM.FirstName# #FORM.LastName#<br>
                            Est Start Date: #DateFormat(FORM.EstStartDate, "mm/dd/yyyy")# <br>
                            Exempt: #( isDefined("FORM.Exempt") ? yes : no )#<br>
                            Full Time: #( isDefined("FORM.FullTime") ? yes : no )#<br>
                            Seasonal: #( isDefined("FORM.Seasonal") ? yes : no )#<br>
                            Primary Position: #( isDefined("FORM.Primary") ? yes : no )#<br>
                            Position Code: #GetPositionInfo.PositionCode#<br>
                            Position Title: #GetPositionInfo.PositionCodeDescription#  <br>
                            Department: #GetDepts.Org#<br>
                            Supervisor: #Supervisor.FirstName# #Supervisor.LastName# <br><br>
                            Cost Code: #FORM.CostCode#   <br>
                            Leave Eligible: #( isDefined("FORM.Leave") ? yes : no )#<br>
                            Benefits Eligible: #( isDefined("FORM.Benefits") ? yes : no )#<br>
                            Salary/Hourly: #GetSalaryHourly.PersonCode#<br>
                            Hours Per Week: #FORM.HoursPerWeek#<br>
                            Pay Rate: $#FORM.PayRate#<br>
                            Frequency: #GetFrequency.PayRateFrequencyCode# <br>
                            Annual Rate: $#(FORM.PayRate * GetFrequency.AnnualizingFactor)#<br/>
                            Comments: #FORM.Notes#                            
                        </p>
                    </td>
                </tr>
            </table>                        
            </cfmail>
            </cfoutput>
            <cflocation url="confirmation.cfm" addtoken="true">
        </cfcase>
    </cfswitch>
</cfif>
<!--- SCFStep2 --->


<!--- SCFStep3 --->
<cfif url.SCFStep3 eq "update">
    <cfparam default="0" name="url.NoShow" />
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST">      
            <cfscript>
                import models.*;
                StepAction = EntityLoad ("StepActions", FORM.StepID);
                employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                employee = employee[1];
                StepAction = stepAction[1];
                employee.setActStartDate( FORM.DateofHire );
                employee.setSSN( FORM.SSN );
                employee.setEthnicID( FORM.EthnicID );
                employee.setGenderID( FORM.GenderID );
                employee.setMaritalStatusID( FORM.MaritalStatusID );
                employee.setI9( FORM.I9 );
                employee.setDOB( FORM.DOB );
                employee.setOrientationNoShow( url.NoShow );                
                EntitySave(employee);
                
                StepAction.setNotes( FORM.Notes );
                if( URL.NoShow == 1 ){
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Orientation No Show - #FORM.Notes#' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                }
                
                EntitySave(StepAction);
                
                helperTools = CreateObject("component", session.RootDir & ".utilities.helperTools");
                Cleared = helperTools.EPLSCheck('#employee.getFirstName()#', '#employee.getLastName()#', '#FORM.SSN#', #employee.getEmployeeID()#);
                
                if( Cleared ){
                    if( URL.NoShow == 0 ){
                        location( '../SCF/Step3-Beneficaries.cfm?StepID=#FORM.StepID#', false);
                    }else{
                        location( '../status.cfm', false);
                    }
                }else{
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID(employee.getEmployeeID());
                    InsertAction.setStepsID(16);
                    InsertAction.setCreationTimeStamp(now());
                    StepID = InsertAction.getStepActionsID();
                    EntitySave(InsertAction, true);
                    location("../SCF/Step3-OrientationEPLSFailed.cfm?StepID=#StepID#");
                }
            </cfscript>
        </cfcase>
    </cfswitch>
</cfif>
<!--- SCFStep3 --->


<!--- Step3 Complete --->
<cfif url.SCFStep3 eq "complete" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfscript>
                import models.*;
                StepAction = EntityLoad ("StepActions", FORM.StepID);
                Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                Employee = Employee[1];
                StepAction = StepAction[1];
                StepAction.setActionByID( Session.UserRosettaID );
                StepAction.setNotes( 'Completion of contacts' );
                StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                EntitySave(StepAction);
                InsertAction = EntityNew("StepActions");
                InsertAction.setEmployeeID( employee.getEmployeeID() );
                InsertAction.setStepsID(4);
                InsertAction.setCreationTimeStamp(now());
                EntitySave(InsertAction, true);
                location("/#session.rootDir#/scf/Step3-SpawnCreation.cfm?StepID=#InsertAction.getStepActionsID()#", false);
            </cfscript>
        </cfcase>    
    </cfswitch>
</cfif>
<!--- Step3 Complete --->

    
<!--- Step3 EPLS --->
<cfif url.SCFStep3 eq "EPLS" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfscript>
                import models.*;
                if( FORM.EPLS EQ 1){
                    StepAction = EntityLoad ("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( FORM.Comments );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID( employee.getEmployeeID() );
                    InsertAction.setStepsID(4);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    location("/#session.rootDir#/scf/Step3-SpawnCreation.cfm?StepID=#InsertAction.getStepActionsID()#", false);
                }else{
                    StepAction = EntityLoad ("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( FORM.Comments );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    location("/#session.rootDir#/status.cfm", false);
                }
            </cfscript>
        </cfcase>    
    </cfswitch>
</cfif>
<!--- Step3 EPLS --->


<!--- Step4 --->
<cfif url.SCFStep4 eq "update" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfparam default="-1" name="FORM.BadgeID" />
            <cftry>
            	<cfscript>
	                import models.*;                
	                StepAction = EntityLoad("StepActions", FORM.StepID);
	                Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
	                Employee = Employee[1];
	                Badge = EntityLoad("Badges", Employee.getRosettaID());
                    if( ArrayLen(Badge) eq 0){
                        NewBadge = EntityNew("Badges");
                        NewBadge.setRosettaID(Employee.getRosettaID());
                        NewBadge.setBadgeNumber(FORM.BadgeID);
                        EntitySave(NewBadge, true);                      
                    }else{
                        Badge = Badge[1];
                        Badge.setBadgeNumber(FORM.BadgeID);
                        EntitySave(Badge);
                    }                
                    
                    Rosetta = EntityLoad("RosettaStone", Employee.getRosettaID());
                    Rosetta = Rosetta[1];
                    Rosetta.setIVIS_IDX(FORM.BadgeID);
                    EntitySave(Rosetta);
                    
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Completion of Badge Number' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID( Employee.getEmployeeID() );
                    InsertAction.setStepsID(6);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    location("../status.cfm", false);
	            </cfscript>            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>

        </cfcase>    
    </cfswitch>
</cfif>
<!--- Step4 --->


<!--- Step5 --->
<cfif url.SCFStep5 eq "update" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfparam default="-1" name="FORM.EmployeeNumber" />
            <cftry>
                <cfscript>
                    import models.*;                
                    StepAction = EntityLoad("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    kq = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
                    Employee = Employee[1];
                    Rosetta = EntityLoad("RosettaStone", Employee.getRosettaID());
                    Rosetta = Rosetta[1];
                    Rosetta.setFundware_EmpNo(FORM.EmployeeNumber);
                    EntitySave(Rosetta);
                    
                    kq.funcUpdateKronosHR(Rosetta.getHRProd_PersonIDNo(), Rosetta.getFundware_EmpNo(), Rosetta.getUserAccount());
                    
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Completion of Employee Number' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID( Employee.getEmployeeID() );
                    InsertAction.setStepsID(7);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    location("../status.cfm", false);
                </cfscript>            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>

        </cfcase>    
    </cfswitch>
</cfif>
<!--- Step5 --->


<!--- Step6 --->
<cfif url.SCFStep6 eq "update" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfparam default="-1" name="FORM.AccessID" />
            <cftry>
                <cfscript>
                    import models.*;                
                    StepAction = EntityLoad("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    Rosetta = EntityLoad("RosettaStone", Employee.getRosettaID());
                    Rosetta = Rosetta[1];
                    Rosetta.setAccessControl_ID(FORM.AccessID);
                    EntitySave(Rosetta);
                    
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Completion of Employee Access Control' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    location("../status.cfm", false);
                </cfscript>            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>

        </cfcase>    
    </cfswitch>
</cfif>
<!--- Step6 --->




<!---*************************** NONSCF ************************--->
<!---*************************** NONSCF ************************--->
<!---*************************** NONSCF ************************--->
<!---*************************** NONSCF ************************--->



<!--- NonSCFStep1 --->
<cfif url.NonSCFStep1 eq "add">
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST">
            <cfscript>
                import models.*;
                employee = EntityNew("Employee");
                employee.setFirstName( FORM.FirstName );
                employee.setLastName( FORM.LastName );
                employee.setMiddleName( FORM.MiddleName );
                employee.setPreferredName( FORM.PreferredName );
                employee.setDepartmentID( FORM.DepartmentID );
                employee.setMirrorAccountID( 0 );
                employee.setBadgeAccessLevelID( ( isDefined("FORM.BadgeAccessLevelID") ? FORM.BadgeAccessLevelID : 0));
                employee.setBadgePos( FORM.BadgePos );
                employee.setCompanyName( FORM.Company );
                employee.setContainerID( FORM.ContainerID );
                employee.setNonSCFTypeID( FORM.NonSCFTypeID );
                employee.setEstStartDate( FORM.EstStartDate );
                employee.setDeskPhone( FORM.DeskPhone );
                employee.setSupervisorID( Session.EmpInfo.MasterID );
                employee.setExpirationDate( dateformat(dateadd('m',1,FORM.EstStartDate),'mm/dd/yyyy') );
                employee.setSSN( FORM.SSN );
                ( isDefined("FORM.NonSCFNetworkAccount") ? employee.setNonSCFNetworkAccount( 1 ) : employee.setNonSCFNetworkAccount( 0 ) );
                ( isDefined("FORM.NonSCFBadge") ? employee.setNonSCFBadge( 1 ) : employee.setNonSCFBadge( 0 ) );
                EntitySave(employee, true);
                
                helperTools = CreateObject("component", session.RootDir & ".utilities.helperTools");
                Cleared = helperTools.EPLSCheck('#employee.getFirstName()#', '#employee.getLastName()#', '#employee.getSSN()#', #employee.getEmployeeID()#);
                
                if( Cleared ){
                    stepAction = EntityNew("StepActions");
                    stepAction.setEmployeeID(employee.getEmployeeID());
                    stepAction.setStepsID(1);
                    stepAction.setActionByID(Session.UserRosettaID);
                    stepAction.setCreationTimeStamp(now());
                    stepAction.setNotes(replace(trim(FORM.Comments),"'","''","all"));
                    EntitySave(stepAction, true);
                    
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID(employee.getEmployeeID());
                    InsertAction.setStepsID(3);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    
                }else{
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID(employee.getEmployeeID());
                    InsertAction.setStepsID(16);
                    InsertAction.setCreationTimeStamp(now());
                    StepID = InsertAction.getStepActionsID();
                    EntitySave(InsertAction, true);
                    location("../NonSCF/Step1-OrientationEPLSFailed.cfm?StepID=#StepID#");
                }
                
                Session.StepConfirmation = 'The requests for account and badge for ';
                Session.StepConfirmation &= FORM.FirstName & " " & ( FORM.PreferredName NEQ "" ? "(" & FORM.PreferredName & ")" : "") & " " & ( FORM.MiddleName NEQ "" ? FORM.MiddleName : "" ) & " " & FORM.LastName;
                Session.StepConfirmation &= " has been successfully submitted to HR.  Please wait for confirmation of offer acceptance and estimated start date.  Thank you for using E-PAR. <p>Hire another employee? Click <a href='../NonSCF/Step1-Request.cfm'>Here</a>";
                location("confirmation.cfm");
            </cfscript>
        </cfcase>
    </cfswitch>
</cfif>
<!--- NonSCFStep1 --->


<!--- NonSCFStep3 --->
<cfif url.NonSCFStep3 eq "update">
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST">
            <cfscript>
                import models.*;
                StepAction = EntityLoad("StepActions", FORM.StepID);
                StepAction = stepAction[1];
                employee = entityLoadByPK("Employee", StepAction.getEmployeeID());                
                employee.setFirstName( FORM.FirstName );
                employee.setLastName( FORM.LastName );
                employee.setMiddleName( FORM.MiddleName );
                employee.setPreferredName( FORM.PreferredName );
                employee.setDepartmentID( FORM.DepartmentID );
                employee.setMirrorAccountID( 0 );
                employee.setBadgeAccessLevelID( ( isDefined("FORM.BadgeAccessLevelID") ? FORM.BadgeAccessLevelID : 0) );
                employee.setBadgePos( FORM.BadgePos );
                employee.setCompanyName( FORM.CompanyName );
                employee.setContainerID( FORM.ContainerID );
                employee.setNonSCFTypeID( FORM.NonSCFTypeID );
                employee.setEstStartDate( FORM.EstStartDate );
                employee.setDeskPhone( FORM.DeskPhone );
                employee.setSupervisorID( FORM.SupervisorID );
                employee.setExpirationDate( dateformat(dateadd('m',1,FORM.EstStartDate),'mm/dd/yyyy') );
                employee.setSSN( FORM.SSN );
                ( isDefined("FORM.NonSCFNetworkAccount") ? employee.setNonSCFNetworkAccount( 1 ) : employee.setNonSCFNetworkAccount( 0 ) );
                ( isDefined("FORM.NonSCFBadge") ? employee.setNonSCFBadge( 1 ) : employee.setNonSCFBadge( 0 ) );
                EntitySave(employee, true);
                
                StepAction.setNotes( FORM.Comments );
                StepAction.setActionByID( Session.UserRosettaID );
                StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );                
                EntitySave(StepAction);
                
                InsertAction = EntityNew("StepActions");
                InsertAction.setEmployeeID(employee.getEmployeeID());
                InsertAction.setStepsID(4);
                InsertAction.setCreationTimeStamp(now());                
                EntitySave(InsertAction, true);
                StepID = InsertAction.getStepActionsID();
                location("../Nonscf/Step3-SpawnCreation.cfm?StepID=#StepID#", false);
            </cfscript>
        </cfcase>
    </cfswitch>
</cfif>
<!--- NonSCFStep3 --->


<!--- NonSCFStep3 EPLS --->
<cfif url.NonSCFStep3 eq "EPLS" >
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfscript>
                import models.*;
                if( FORM.EPLS EQ 1){
                    StepAction = EntityLoad ("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( FORM.Comments );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID( employee.getEmployeeID() );
                    InsertAction.setStepsID(4);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    location("/#session.rootDir#/nonscf/Step3-SpawnCreation.cfm?StepID=#InsertAction.getStepActionsID()#", false);
                }else{
                    StepAction = EntityLoad ("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( FORM.Comments );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    location("/#session.rootDir#/status.cfm", false);
                }
            </cfscript>
        </cfcase>    
    </cfswitch>
</cfif>
<!--- NonSCFStep3 EPLS --->


<!--- NonSCFStep4 --->
<cfif url.NonSCFStep4 eq "update">
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST">
            <cftry>
                <cfscript>
                    import models.*;                
                    StepAction = EntityLoad("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    Badge = EntityLoad("Badges", Employee.getRosettaID());
                    if( ArrayLen(Badge) eq 0){
                        NewBadge = EntityNew("Badges");
                        NewBadge.setRosettaID(Employee.getRosettaID());
                        NewBadge.setBadgeNumber(FORM.BadgeID);
                        EntitySave(NewBadge, true);                      
                    }else{
                        Badge = Badge[1];
                        Badge.setBadgeNumber(FORM.BadgeID);
                        EntitySave(Badge);
                    }                
                    
                    Rosetta = EntityLoad("RosettaStone", Employee.getRosettaID());
                    Rosetta = Rosetta[1];
                    Rosetta.setIVIS_IDX(FORM.BadgeID);
                    EntitySave(Rosetta);
                    
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Completion of Badge Number' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    InsertAction = EntityNew("StepActions");
                    InsertAction.setEmployeeID( Employee.getEmployeeID() );
                    InsertAction.setStepsID(7);
                    InsertAction.setCreationTimeStamp(now());
                    EntitySave(InsertAction, true);
                    location("../status.cfm", false);
                </cfscript>            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>
        </cfcase>
    </cfswitch>
</cfif>
<!--- NonSCFStep4 --->


<!--- NonSCFStep6 --->
<cfif url.NonSCFStep6 eq "update">
    <cfswitch expression="#CGI.REQUEST_METHOD#">
        <cfcase value="POST" >
            <cfparam default="-1" name="FORM.AccessID" />
            <cftry>
                <cfscript>
                    import models.*;                
                    StepAction = EntityLoad("StepActions", FORM.StepID);
                    Employee = EntityLoad("Employee", StepAction[1].getEmployeeID());
                    Employee = Employee[1];
                    Rosetta = EntityLoad("RosettaStone", Employee.getRosettaID());
                    Rosetta = Rosetta[1];
                    Rosetta.setAccessControl_ID(FORM.AccessID);
                    EntitySave(Rosetta);
                    
                    StepAction = StepAction[1];
                    StepAction.setActionByID( Session.UserRosettaID );
                    StepAction.setNotes( 'Completion of Employee Access Control' );
                    StepAction.setActTimeStamp( DateFormat(now(), 'mm/dd/yyyy') );
                    EntitySave(StepAction);
                    location("../status.cfm", false);
                </cfscript>            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>

        </cfcase>    
    </cfswitch>
</cfif>
<!--- NonSCFStep6 --->